package ecom.beans;

import javax.ejb.Remote;
import javax.ejb.Stateful;
import javax.ejb.SessionSynchronization;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateful
@Remote(EcomAdminRemote.class)
public class EcomAdminBean implements EcomAdminRemote{
    
    @PersistenceContext
    private EntityManager manager;
    
    public EcomAdminBean(){
    }
    
    public EntityManager getManager(){return this.manager;}
    public void setManager(EntityManager em){this.manager = em;}
    
    public void createAccount(int accountId, String accountOwner, double balance) {
	// to be completed
	System.out.println("create account"+accountId+" - "+accountOwner);
	AccountBean acc = new AccountBean(accountId,accountOwner,balance);
	System.out.println("done");
	getManager().persist(acc);
    }
    public void createProductStore(int productStoreId, String city, int productStoreAccountId, String productStoreName){
	// to be completed
	ProductStoreBean psb = new ProductStoreBean(productStoreId,city,productStoreAccountId,productStoreName);
	getManager().persist(psb);
    }
    public void createProduct(int productId, String productName, double productPrice, int productStoreId, String city){
	// to be completed
	ProductBean product = new ProductBean(productId,productName,productPrice,productStoreId,city);
	getManager().persist(product);
    }
    
}